package cn.guestbook.dao.impl;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import cn.guestbook.dao.PostDAO;
import cn.guestbook.model.Post;

public class PostDAOImpl  extends HibernateDaoSupport implements PostDAO {

	public void add(Post post) throws DataAccessException {
		getHibernateTemplate().save(post);
		
	}

	public void deleteById(Integer id) throws DataAccessException {
		String hql = "delete from Post where postId = ?";
		getHibernateTemplate().bulkUpdate(hql ,id);
		
	}

	@SuppressWarnings("unchecked")
	public List<Post> findAll() throws DataAccessException {
		return getHibernateTemplate().find("from Post");
	}

	
}
